package homework.valid.validators.impl;

import homework.valid.validators.BaseValidator;

import java.util.regex.Pattern;

public class RegularValidator extends BaseValidator {

    private Pattern p;

    public RegularValidator(String msg, String expr) {
        super(msg);
        p = Pattern.compile(expr);
    }

    @Override
    public boolean isValid(Object v) {
        return p.matcher(v.toString()).matches();
    }
}
